package org.javaboy.sms_service.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitConfig {

    // 交换机名称
    public static final String SEND_SMS_EXCHANGE = "send_sms_exchange";
    // 队列名称
    public static final String SEND_SMS_QUEUE = "send_sms_queue";

    @Bean
    Queue myQueue() {
        return new Queue(SEND_SMS_QUEUE, true, false, false);
    }

    @Bean
    DirectExchange myExchange() {
        return new DirectExchange(SEND_SMS_EXCHANGE, true, false);
    }

    @Bean
    Binding myBinding() {
        return BindingBuilder.bind(myQueue()).to(myExchange()).withQueueName();
    }
}
